package com.itheima.mall.web.oss;

import com.itheima.mall.service.oss.AliyunService;
import com.itheima.mall.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/aliyun")
public class OssController {
    @Autowired
    private AliyunService aliyunService;

    @PostMapping("/oss/upload")
    public R upload(MultipartFile photoFile)  {
        String url = aliyunService.upload(photoFile);
        Map<String,String> map = new HashMap<>();
        map.put("url",url);
        return R.succeed(map,"操作成功");
    }
}
